using System;
using System.Data.SqlClient;

/// <summary>
/// A class that represents a Cmdlet Parameter
/// </summary>
public class PsSpecCmdletParameter : IPsSpecDataReader
{
    public PsSpecCmdletParameter() { }

    public void Initialize(SqlDataReader reader, System.Collections.Generic.Dictionary<string, Int32> columnMappings)
    {
        SqlUtils.ElementConverter<Int32> intConverter = IntConverter;
        SqlUtils.ElementConverter<String> stringConverter = StringConverter;

        this.id = reader.GetInt32(columnMappings["Id"]);
        this.projectName = reader[columnMappings["ProjectName"]] as string;
        this.cmdletName = reader[columnMappings["CmdletName"]] as string;
        this.parameterName = reader[columnMappings["Name"]] as string;
        this.type = reader[columnMappings["Type"]] as string;
        this.description = reader[columnMappings["Description"]] as string;
        this.alias = SqlUtils.CreateArray<String>(reader[columnMappings["Aliases"]] as string, stringConverter);
        this.allowGlobbing = reader.GetBoolean(columnMappings["AllowGlobbing"]);
        this.allowMultiple = reader.GetBoolean(columnMappings["AllowMultiple"]);
        this.isDynamic = reader.GetBoolean(columnMappings["IsDynamic"]);
        this.allowEmptyCollection = reader.GetBoolean(columnMappings["AllowEmptyCollection"]);
        this.allowEmptyString = reader.GetBoolean(columnMappings["AllowEmptyString"]);
        this.allowNull = reader.GetBoolean(columnMappings["AllowNull"]);
        this.validateCount = SqlUtils.CreateArray<Int32>(reader[columnMappings["ValidateCount"]] as string, intConverter);
        this.validateNotNull = reader.GetBoolean(columnMappings["ValidateNotNull"]);
        this.validateNotNullOrEmpty = reader.GetBoolean(columnMappings["ValidateNotNullOrEmpty"]);
        this.validateRange = SqlUtils.CreateArray<Int32>(reader[columnMappings["ValidateRange"]] as string, intConverter);
        this.validateSet = SqlUtils.CreateArray<String>(reader[columnMappings["ValidateSet"]] as string, stringConverter);
        this.validateLength = SqlUtils.CreateArray<Int32>(reader[columnMappings["ValidateLength"]] as string, intConverter);
        this.validatePattern = reader[columnMappings["ValidatePattern"]] as string;
        this.notes = reader[columnMappings["Notes"]] as string;
        this.defaultValue = reader[columnMappings["DefaultValue"]] as string;
        this.custom1 = reader[columnMappings["Custom1"]] as string;
        this.custom2 = reader[columnMappings["Custom2"]] as string;
        this.custom3 = reader[columnMappings["Custom3"]] as string;
        this.custom4 = reader[columnMappings["Custom4"]] as string;
        this.helpDescription = reader[columnMappings["HelpDescription"]] as string;
    }

    public int Id
    {
        get { return id; }
        set { id = value; }
    }
    private int id;

    public string ProjectName
    {
        get { return projectName; }
        set { projectName = value; }
    }
    private string projectName = null;

    public string CmdletName
    {
        get { return cmdletName; }
        set { cmdletName = value; }
    }
    private string cmdletName = null;

    public string Name
    {
        get { return parameterName; }
        set { parameterName = value; }
    }
    private string parameterName = null;

    public string Type
    {
        get { return type; }
        set { type = value; }
    }
    private string type = null;

    public string Description
    {
        get { return description; }
        set { description = value; }
    }
    private string description = null;

    public string[] Alias
    {
        get { return alias; }
        set { alias = value; }
    }
    private string[] alias = null;

    public bool AllowGlobbing
    {
        get { return allowGlobbing; }
        set { allowGlobbing = value; }
    }
    private bool allowGlobbing;

    public bool AllowMultiple
    {
        get { return allowMultiple; }
        set { allowMultiple = value; }
    }
    private bool allowMultiple;

    public bool IsDynamic
    {
        get { return isDynamic; }
        set { isDynamic = value; }
    }
    private bool isDynamic;

    public bool AllowEmptyCollection
    {
        get { return allowEmptyCollection; }
        set { allowEmptyCollection = value; }
    }
    private bool allowEmptyCollection;

    public bool AllowEmptyString
    {
        get { return allowEmptyString; }
        set { allowEmptyString = value; }
    }
    private bool allowEmptyString;

    public bool AllowNull
    {
        get { return allowNull; }
        set { allowNull = value; }
    }
    private bool allowNull;

    public int[] ValidateCount
    {
        get { return validateCount; }
        set { validateCount = value; }
    }
    private int[] validateCount = null;

    public bool ValidateNotNull
    {
        get { return validateNotNull; }
        set { validateNotNull = value; }
    }
    private bool validateNotNull;

    public bool ValidateNotNullOrEmpty
    {
        get { return validateNotNullOrEmpty; }
        set { validateNotNullOrEmpty = value; }
    }
    private bool validateNotNullOrEmpty;

    public int[] ValidateRange
    {
        get { return validateRange; }
        set { validateRange = value; }
    }
    private int[] validateRange = null;

    public string[] ValidateSet
    {
        get { return validateSet; }
        set { validateSet = value; }
    }
    private string[] validateSet = null;

    public int[] ValidateLength
    {
        get { return validateLength; }
        set { validateLength = value; }
    }
    private int[] validateLength = null;

    public string ValidatePattern
    {
        get { return validatePattern; }
        set { validatePattern = value; }
    }
    private string validatePattern = null;

    public string Note
    {
        get { return notes; }
        set { notes = value; }
    }
    private string notes = null;

    public String DefaultValue
    {
        get { return defaultValue; }
        set { defaultValue = value; }
    }
    private string defaultValue;

    public String Custom1
    {
        get { return custom1; }
        set { custom1 = value; }
    }
    private string custom1;


    public String Custom2
    {
        get { return custom2; }
        set { custom2 = value; }
    }
    private string custom2;


    public String Custom3
    {
        get { return custom3; }
        set { custom3 = value; }
    }
    private string custom3;


    public String Custom4
    {
        get { return custom4; }
        set { custom4 = value; }
    }
    private string custom4;


    public String HelpDescription
    {
        get { return helpDescription; }
        set { helpDescription = value; }
    }
    private string helpDescription;

    private Int32 IntConverter(string input) { return Int32.Parse(input); }
    private String StringConverter(string input) { return input; }
}
